#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;


int minimumAddedInteger(vector<int>& nums1, vector<int>& nums2) {
    sort(nums1.begin(), nums1.end());
    sort(nums2.begin(), nums2.end());
    int n;
    int max = nums2.size()-1;
    int n1 = nums2[max] - nums1[max+2];
    int n2 = nums1[max-1] - nums2[max+1];
    int n3 = nums1[max-2] - nums2[max];
    int n4 = nums1[max-3] - nums2[max-1];
    int n5 = nums1[max-4] - nums2[max-2];
    int m1 = n1;
    int m2;
    int count1=0;
    int count2=0;
    if(n2!=m1)
        m2 = n2;
    else
        count1++;
    if(n3!=m1)
        
    return 0;
}
int main()
{
    vector<int> a;
    vector<int> b;
    int x1, x2;
    while(x1!=-1)
    {
        cin >> x1;
        a.push_back(x1);
    }
    a.erase(a.end()-1);
    while(x2!=-1)
    {
        cin >> x2;
        b.push_back(x2);
    }
    b.erase(b.end()-1);
    cout << minimumAddedInteger(a, b);
    return 0;
}
